
<!DOCTYPE HTML>
<html lang="zh-hans" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>11.5 将Conda包作为依赖项发布给项目 · 《CMake Cookbook》中文版</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        <meta name="author" content="陈晓伟 chenxiaowei">
        
        
    
    <link rel="stylesheet" href="../../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-search-pro/search.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-pageview-count/plugin.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="../chapter12/12.0-chinese.html" />
    
    
    <link rel="prev" href="11.4-chinese.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="输入并搜索" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../../">
            
                <a href="../../">
            
                    
                    Introduction
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="../preface/preface-chinese.html">
            
                <a href="../preface/preface-chinese.html">
            
                    
                    前言
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="../chapter0/0.0-chinese.html">
            
                <a href="../chapter0/0.0-chinese.html">
            
                    
                    第0章 配置环境
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.1" data-path="../chapter0/0.1-chinese.html">
            
                <a href="../chapter0/0.1-chinese.html">
            
                    
                    0.1 获取代码
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.2" data-path="../chapter0/0.2-chinese.html">
            
                <a href="../chapter0/0.2-chinese.html">
            
                    
                    0.2 Docker镜像
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.3" data-path="../chapter0/0.3-chinese.html">
            
                <a href="../chapter0/0.3-chinese.html">
            
                    
                    0.3 安装必要的软件
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.4" data-path="../chapter0/0.4-chinese.html">
            
                <a href="../chapter0/0.4-chinese.html">
            
                    
                    0.4 测试环境
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.5" data-path="../chapter0/0.5-chinese.html">
            
                <a href="../chapter0/0.5-chinese.html">
            
                    
                    0.5 上报问题并提出改进建议
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="../chapter1/1.0-chinese.html">
            
                <a href="../chapter1/1.0-chinese.html">
            
                    
                    第1章 从可执行文件到库
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.4.1" data-path="../chapter1/1.1-chinese.html">
            
                <a href="../chapter1/1.1-chinese.html">
            
                    
                    1.1 将单个源文件编译为可执行文件
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.2" data-path="../chapter1/1.2-chinese.html">
            
                <a href="../chapter1/1.2-chinese.html">
            
                    
                    1.2 切换生成器
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.3" data-path="../chapter1/1.3-chinese.html">
            
                <a href="../chapter1/1.3-chinese.html">
            
                    
                    1.3 构建和链接静态库和动态库
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.4" data-path="../chapter1/1.4-chinese.html">
            
                <a href="../chapter1/1.4-chinese.html">
            
                    
                    1.4 用条件句控制编译
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.5" data-path="../chapter1/1.5-chinese.html">
            
                <a href="../chapter1/1.5-chinese.html">
            
                    
                    1.5 向用户显示选项
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.6" data-path="../chapter1/1.6-chinese.html">
            
                <a href="../chapter1/1.6-chinese.html">
            
                    
                    1.6 指定编译器
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.7" data-path="../chapter1/1.7-chinese.html">
            
                <a href="../chapter1/1.7-chinese.html">
            
                    
                    1.7 切换构建类型
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.8" data-path="../chapter1/1.8-chinese.html">
            
                <a href="../chapter1/1.8-chinese.html">
            
                    
                    1.8 设置编译器选项
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.9" data-path="../chapter1/1.9-chinese.html">
            
                <a href="../chapter1/1.9-chinese.html">
            
                    
                    1.9 为语言设定标准
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.10" data-path="../chapter1/1.10-chinese.html">
            
                <a href="../chapter1/1.10-chinese.html">
            
                    
                    1.10 使用控制流
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.5" data-path="../chapter2/2.0-chinese.html">
            
                <a href="../chapter2/2.0-chinese.html">
            
                    
                    第2章 检测环境
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.5.1" data-path="../chapter2/2.1-chinese.html">
            
                <a href="../chapter2/2.1-chinese.html">
            
                    
                    2.1 检测操作系统
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.2" data-path="../chapter2/2.2-chinese.html">
            
                <a href="../chapter2/2.2-chinese.html">
            
                    
                    2.2 处理与平台相关的源代码
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.3" data-path="../chapter2/2.3-chinese.html">
            
                <a href="../chapter2/2.3-chinese.html">
            
                    
                    2.3 处理与编译器相关的源代码
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.4" data-path="../chapter2/2.4-chinese.html">
            
                <a href="../chapter2/2.4-chinese.html">
            
                    
                    2.4 检测处理器体系结构
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.5" data-path="../chapter2/2.5-chinese.html">
            
                <a href="../chapter2/2.5-chinese.html">
            
                    
                    2.5 检测处理器指令集
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.6" data-path="../chapter2/2.6-chinese.html">
            
                <a href="../chapter2/2.6-chinese.html">
            
                    
                    2.6 为Eigen库使能向量化
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.6" data-path="../chapter3/3.0-chinese.html">
            
                <a href="../chapter3/3.0-chinese.html">
            
                    
                    第3章 检测外部库和程序
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.6.1" data-path="../chapter3/3.1-chinese.html">
            
                <a href="../chapter3/3.1-chinese.html">
            
                    
                    3.1 检测Python解释器
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.2" data-path="../chapter3/3.2-chinese.html">
            
                <a href="../chapter3/3.2-chinese.html">
            
                    
                    3.2 检测Python库
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.3" data-path="../chapter3/3.3-chinese.html">
            
                <a href="../chapter3/3.3-chinese.html">
            
                    
                    3.3 检测Python模块和包
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.4" data-path="../chapter3/3.4-chinese.html">
            
                <a href="../chapter3/3.4-chinese.html">
            
                    
                    3.4 检测BLAS和LAPACK数学库
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.5" data-path="../chapter3/3.5-chinese.html">
            
                <a href="../chapter3/3.5-chinese.html">
            
                    
                    3.5 检测OpenMP的并行环境
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.6" data-path="../chapter3/3.6-chinese.html">
            
                <a href="../chapter3/3.6-chinese.html">
            
                    
                    3.6 检测MPI的并行环境
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.7" data-path="../chapter3/3.7-chinese.html">
            
                <a href="../chapter3/3.7-chinese.html">
            
                    
                    3.7 检测Eigen库
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.8" data-path="../chapter3/3.8-chinese.html">
            
                <a href="../chapter3/3.8-chinese.html">
            
                    
                    3.8 检测Boost库
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.9" data-path="../chapter3/3.9-chinese.html">
            
                <a href="../chapter3/3.9-chinese.html">
            
                    
                    3.9 检测外部库:Ⅰ. 使用pkg-config
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.10" data-path="../chapter3/3.10-chinese.html">
            
                <a href="../chapter3/3.10-chinese.html">
            
                    
                    3.10 检测外部库:Ⅱ. 自定义find模块
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.7" data-path="../chapter4/4.0-chinese.html">
            
                <a href="../chapter4/4.0-chinese.html">
            
                    
                    第4章 创建和运行测试
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.7.1" data-path="../chapter4/4.1-chinese.html">
            
                <a href="../chapter4/4.1-chinese.html">
            
                    
                    4.1 创建一个简单的单元测试
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.2" data-path="../chapter4/4.2-chinese.html">
            
                <a href="../chapter4/4.2-chinese.html">
            
                    
                    4.2 使用Catch2库进行单元测试
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.3" data-path="../chapter4/4.3-chinese.html">
            
                <a href="../chapter4/4.3-chinese.html">
            
                    
                    4.3 使用Google Test库进行单元测试
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.4" data-path="../chapter4/4.4-chinese.html">
            
                <a href="../chapter4/4.4-chinese.html">
            
                    
                    4.4 使用Boost Test进行单元测试
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.5" data-path="../chapter4/4.5-chinese.html">
            
                <a href="../chapter4/4.5-chinese.html">
            
                    
                    4.5 使用动态分析来检测内存缺陷
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.6" data-path="../chapter4/4.6-chinese.html">
            
                <a href="../chapter4/4.6-chinese.html">
            
                    
                    4.6 预期测试失败
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.7" data-path="../chapter4/4.7-chinese.html">
            
                <a href="../chapter4/4.7-chinese.html">
            
                    
                    4.7 使用超时测试运行时间过长的测试
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.8" data-path="../chapter4/4.8-chinese.html">
            
                <a href="../chapter4/4.8-chinese.html">
            
                    
                    4.8 并行测试
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.9" data-path="../chapter4/4.9-chinese.html">
            
                <a href="../chapter4/4.9-chinese.html">
            
                    
                    4.9 运行测试子集
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.10" data-path="../chapter4/4.10-chinese.html">
            
                <a href="../chapter4/4.10-chinese.html">
            
                    
                    4.10 使用测试固件
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.8" data-path="../chapter5/5.0-chinese.html">
            
                <a href="../chapter5/5.0-chinese.html">
            
                    
                    第5章 配置时和构建时的操作
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.8.1" data-path="../chapter5/5.1-chinese.html">
            
                <a href="../chapter5/5.1-chinese.html">
            
                    
                    5.1 使用平台无关的文件操作
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.2" data-path="../chapter5/5.2-chinese.html">
            
                <a href="../chapter5/5.2-chinese.html">
            
                    
                    5.2 配置时运行自定义命令
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.3" data-path="../chapter5/5.3-chinese.html">
            
                <a href="../chapter5/5.3-chinese.html">
            
                    
                    5.3 构建时运行自定义命令:Ⅰ. 使用add_custom_command
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.4" data-path="../chapter5/5.4-chinese.html">
            
                <a href="../chapter5/5.4-chinese.html">
            
                    
                    5.4 构建时运行自定义命令:Ⅱ. 使用add_custom_target
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.5" data-path="../chapter5/5.5-chinese.html">
            
                <a href="../chapter5/5.5-chinese.html">
            
                    
                    5.5 构建时为特定目标运行自定义命令
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.6" data-path="../chapter5/5.6-chinese.html">
            
                <a href="../chapter5/5.6-chinese.html">
            
                    
                    5.6 探究编译和链接命令
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.7" data-path="../chapter5/5.7-chinese.html">
            
                <a href="../chapter5/5.7-chinese.html">
            
                    
                    5.7 探究编译器标志命令
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.8" data-path="../chapter5/5.8-chinese.html">
            
                <a href="../chapter5/5.8-chinese.html">
            
                    
                    5.8 探究可执行命令
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.9" data-path="../chapter5/5.9-chinese.html">
            
                <a href="../chapter5/5.9-chinese.html">
            
                    
                    5.9 使用生成器表达式微调配置和编译
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.9" data-path="../chapter6/6.0-chinese.html">
            
                <a href="../chapter6/6.0-chinese.html">
            
                    
                    第6章 生成源码
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.9.1" data-path="../chapter6/6.1-chinese.html">
            
                <a href="../chapter6/6.1-chinese.html">
            
                    
                    6.1 配置时生成源码
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.2" data-path="../chapter6/6.2-chinese.html">
            
                <a href="../chapter6/6.2-chinese.html">
            
                    
                    6.2 使用Python在配置时生成源码
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.3" data-path="../chapter6/6.3-chinese.html">
            
                <a href="../chapter6/6.3-chinese.html">
            
                    
                    6.3 构建时使用Python生成源码
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.4" data-path="../chapter6/6.4-chinese.html">
            
                <a href="../chapter6/6.4-chinese.html">
            
                    
                    6.4 记录项目版本信息以便报告
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.5" data-path="../chapter6/6.5-chinese.html">
            
                <a href="../chapter6/6.5-chinese.html">
            
                    
                    6.5 从文件中记录项目版本
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.6" data-path="../chapter6/6.6-chinese.html">
            
                <a href="../chapter6/6.6-chinese.html">
            
                    
                    6.6 配置时记录Git Hash值
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.7" data-path="../chapter6/6.7-chinese.html">
            
                <a href="../chapter6/6.7-chinese.html">
            
                    
                    6.7 构建时记录Git Hash值
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.10" data-path="../chapter7/7.0-chinese.html">
            
                <a href="../chapter7/7.0-chinese.html">
            
                    
                    第7章 构建项目
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.10.1" data-path="../chapter7/7.1-chinese.html">
            
                <a href="../chapter7/7.1-chinese.html">
            
                    
                    7.1 使用函数和宏重用代码
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.2" data-path="../chapter7/7.2-chinese.html">
            
                <a href="../chapter7/7.2-chinese.html">
            
                    
                    7.2 将CMake源代码分成模块
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.3" data-path="../chapter7/7.3-chinese.html">
            
                <a href="../chapter7/7.3-chinese.html">
            
                    
                    7.3 编写函数来测试和设置编译器标志
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.4" data-path="../chapter7/7.4-chinese.html">
            
                <a href="../chapter7/7.4-chinese.html">
            
                    
                    7.4 用指定参数定义函数或宏
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.5" data-path="../chapter7/7.5-chinese.html">
            
                <a href="../chapter7/7.5-chinese.html">
            
                    
                    7.5 重新定义函数和宏
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.6" data-path="../chapter7/7.6-chinese.html">
            
                <a href="../chapter7/7.6-chinese.html">
            
                    
                    7.6 使用废弃函数、宏和变量
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.7" data-path="../chapter7/7.7-chinese.html">
            
                <a href="../chapter7/7.7-chinese.html">
            
                    
                    7.7 add_subdirectory的限定范围
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.8" data-path="../chapter7/7.8-chinese.html">
            
                <a href="../chapter7/7.8-chinese.html">
            
                    
                    7.8 使用target_sources避免全局变量
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.9" data-path="../chapter7/7.9-chinese.html">
            
                <a href="../chapter7/7.9-chinese.html">
            
                    
                    7.9 组织Fortran项目
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.11" data-path="../chapter8/8.0-chinese.html">
            
                <a href="../chapter8/8.0-chinese.html">
            
                    
                    第8章 超级构建模式
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.11.1" data-path="../chapter8/8.1-chinese.html">
            
                <a href="../chapter8/8.1-chinese.html">
            
                    
                    8.1 使用超级构建模式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.2" data-path="../chapter8/8.2-chinese.html">
            
                <a href="../chapter8/8.2-chinese.html">
            
                    
                    8.2 使用超级构建管理依赖项:Ⅰ.Boost库
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.3" data-path="../chapter8/8.3-chinese.html">
            
                <a href="../chapter8/8.3-chinese.html">
            
                    
                    8.3 使用超级构建管理依赖项:Ⅱ.FFTW库
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.4" data-path="../chapter8/8.4-chinese.html">
            
                <a href="../chapter8/8.4-chinese.html">
            
                    
                    8.4 使用超级构建管理依赖项:Ⅲ.Google Test框架
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.5" data-path="../chapter8/8.5-chinese.html">
            
                <a href="../chapter8/8.5-chinese.html">
            
                    
                    8.5 使用超级构建支持项目
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.12" data-path="../chapter9/9.0-chinese.html">
            
                <a href="../chapter9/9.0-chinese.html">
            
                    
                    第9章 语言混合项目
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.12.1" data-path="../chapter9/9.1-chinese.html">
            
                <a href="../chapter9/9.1-chinese.html">
            
                    
                    9.1 使用C/C++库构建Fortran项目
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.2" data-path="../chapter9/9.2-chinese.html">
            
                <a href="../chapter9/9.2-chinese.html">
            
                    
                    9.2 使用Fortran库构建C/C++项目
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.3" data-path="../chapter9/9.3-chinese.html">
            
                <a href="../chapter9/9.3-chinese.html">
            
                    
                    9.3 使用Cython构建C++和Python项目
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.4" data-path="../chapter9/9.4-chinese.html">
            
                <a href="../chapter9/9.4-chinese.html">
            
                    
                    9.4 使用Boost.Python构建C++和Python项目
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.5" data-path="../chapter9/9.5-chinese.html">
            
                <a href="../chapter9/9.5-chinese.html">
            
                    
                    9.5 使用pybind11构建C++和Python项目
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.6" data-path="../chapter9/9.6-chinese.html">
            
                <a href="../chapter9/9.6-chinese.html">
            
                    
                    9.6 使用Python CFFI混合C，C++，Fortran和Python
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.13" data-path="../chapter10/10.0-chinese.html">
            
                <a href="../chapter10/10.0-chinese.html">
            
                    
                    第10章 编写安装程序
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.13.1" data-path="../chapter10/10.1-chinese.html">
            
                <a href="../chapter10/10.1-chinese.html">
            
                    
                    10.1 安装项目
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13.2" data-path="../chapter10/10.2-chinese.html">
            
                <a href="../chapter10/10.2-chinese.html">
            
                    
                    10.2 生成输出头文件
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13.3" data-path="../chapter10/10.3-chinese.html">
            
                <a href="../chapter10/10.3-chinese.html">
            
                    
                    10.3 输出目标
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13.4" data-path="../chapter10/10.4-chinese.html">
            
                <a href="../chapter10/10.4-chinese.html">
            
                    
                    10.4 安装超级构建
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.14" data-path="11.0-chinese.html">
            
                <a href="11.0-chinese.html">
            
                    
                    第11章 打包项目
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.14.1" data-path="11.1-chinese.html">
            
                <a href="11.1-chinese.html">
            
                    
                    11.1 生成源代码和二进制包
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.14.2" data-path="11.2-chinese.html">
            
                <a href="11.2-chinese.html">
            
                    
                    11.2 通过PyPI发布使用CMake/pybind11构建的C++/Python项目
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.14.3" data-path="11.3-chinese.html">
            
                <a href="11.3-chinese.html">
            
                    
                    11.3 通过PyPI发布使用CMake/CFFI构建C/Fortran/Python项目
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.14.4" data-path="11.4-chinese.html">
            
                <a href="11.4-chinese.html">
            
                    
                    11.4 以Conda包的形式发布一个简单的项目
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="1.14.5" data-path="11.5-chinese.html">
            
                <a href="11.5-chinese.html">
            
                    
                    11.5 将Conda包作为依赖项发布给项目
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.15" data-path="../chapter12/12.0-chinese.html">
            
                <a href="../chapter12/12.0-chinese.html">
            
                    
                    第12章 构建文档
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.15.1" data-path="../chapter12/12.1-chinese.html">
            
                <a href="../chapter12/12.1-chinese.html">
            
                    
                    12.1 使用Doxygen构建文档
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.15.2" data-path="../chapter12/12.2-chinese.html">
            
                <a href="../chapter12/12.2-chinese.html">
            
                    
                    12.2 使用Sphinx构建文档
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.15.3" data-path="../chapter12/12.3-chinese.html">
            
                <a href="../chapter12/12.3-chinese.html">
            
                    
                    12.3 结合Doxygen和Sphinx
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.16" data-path="../chapter13/13.0-chinese.html">
            
                <a href="../chapter13/13.0-chinese.html">
            
                    
                    第13章 选择生成器和交叉编译
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.16.1" data-path="../chapter13/13.1-chinese.html">
            
                <a href="../chapter13/13.1-chinese.html">
            
                    
                    13.1 使用CMake构建Visual Studio 2017项目
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.16.2" data-path="../chapter13/13.2-chinese.html">
            
                <a href="../chapter13/13.2-chinese.html">
            
                    
                    13.2 交叉编译hello world示例
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.16.3" data-path="../chapter13/13.3-chinese.html">
            
                <a href="../chapter13/13.3-chinese.html">
            
                    
                    13.3 使用OpenMP并行化交叉编译Windows二进制文件
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.17" data-path="../chapter14/14.0-chinese.html">
            
                <a href="../chapter14/14.0-chinese.html">
            
                    
                    第14章 测试面板
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.17.1" data-path="../chapter14/14.1-chinese.html">
            
                <a href="../chapter14/14.1-chinese.html">
            
                    
                    14.1 将测试部署到CDash
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.17.2" data-path="../chapter14/14.2-chinese.html">
            
                <a href="../chapter14/14.2-chinese.html">
            
                    
                    14.2 CDash显示测试覆盖率
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.17.3" data-path="../chapter14/14.3-chinese.html">
            
                <a href="../chapter14/14.3-chinese.html">
            
                    
                    14.3 使用AddressSanifier向CDash报告内存缺陷
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.17.4" data-path="../chapter14/14.4-chinese.html">
            
                <a href="../chapter14/14.4-chinese.html">
            
                    
                    14.4 使用ThreadSaniiser向CDash报告数据争用
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.18" data-path="../chapter15/15.0-chinese.html">
            
                <a href="../chapter15/15.0-chinese.html">
            
                    
                    第15章 使用CMake构建已有项目
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.18.1" data-path="../chapter15/15.1-chinese.html">
            
                <a href="../chapter15/15.1-chinese.html">
            
                    
                    15.1 如何开始迁移项目
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.18.2" data-path="../chapter15/15.2-chinese.html">
            
                <a href="../chapter15/15.2-chinese.html">
            
                    
                    15.2 生成文件并编写平台检查
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.18.3" data-path="../chapter15/15.3-chinese.html">
            
                <a href="../chapter15/15.3-chinese.html">
            
                    
                    15.3 检测所需的链接和依赖关系
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.18.4" data-path="../chapter15/15.4-chinese.html">
            
                <a href="../chapter15/15.4-chinese.html">
            
                    
                    15.4 复制编译标志
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.18.5" data-path="../chapter15/15.5-chinese.html">
            
                <a href="../chapter15/15.5-chinese.html">
            
                    
                    15.5 移植测试
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.18.6" data-path="../chapter15/15.6-chinese.html">
            
                <a href="../chapter15/15.6-chinese.html">
            
                    
                    15.6 移植安装目标
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.18.7" data-path="../chapter15/15.7-chinese.html">
            
                <a href="../chapter15/15.7-chinese.html">
            
                    
                    15.7 进一步迁移的措施
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.18.8" data-path="../chapter15/15.8-chinese.html">
            
                <a href="../chapter15/15.8-chinese.html">
            
                    
                    15.8 项目转换为CMake的常见问题
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.19" data-path="../chapter16/16.0-chinese.html">
            
                <a href="../chapter16/16.0-chinese.html">
            
                    
                    第16章 可能感兴趣的书
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.19.1" data-path="../chapter16/16.1-chinese.html">
            
                <a href="../chapter16/16.1-chinese.html">
            
                    
                    16.1 留下评论——让其他读者知道你的想法
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="http://www.bczl.xyz/" target="blank" class="gitbook-link">
            编程之路
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href="../.." >11.5 将Conda包作为依赖项发布给项目</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h1 id="115-&#x5C06;conda&#x5305;&#x4F5C;&#x4E3A;&#x4F9D;&#x8D56;&#x9879;&#x53D1;&#x5E03;&#x7ED9;&#x9879;&#x76EE;">11.5 &#x5C06;Conda&#x5305;&#x4F5C;&#x4E3A;&#x4F9D;&#x8D56;&#x9879;&#x53D1;&#x5E03;&#x7ED9;&#x9879;&#x76EE;</h1>
<p><strong>NOTE</strong>:<em>&#x6B64;&#x793A;&#x4F8B;&#x4EE3;&#x7801;&#x53EF;&#x4EE5;&#x5728; <a href="https://github.com/dev-cafe/cmake-cookbook/tree/v1.0/chapter-11/recipe-05" target="_blank">https://github.com/dev-cafe/cmake-cookbook/tree/v1.0/chapter-11/recipe-05</a> &#x4E2D;&#x627E;&#x5230;&#x3002;&#x8BE5;&#x793A;&#x4F8B;&#x5728;CMake 3.5&#x7248;(&#x6216;&#x66F4;&#x9AD8;&#x7248;&#x672C;)&#x4E2D;&#x662F;&#x6709;&#x6548;&#x7684;&#xFF0C;&#x5E76;&#x4E14;&#x5DF2;&#x7ECF;&#x5728;GNU/Linux&#x3001;macOS&#x548C;Windows&#x4E0A;&#x8FDB;&#x884C;&#x8FC7;&#x6D4B;&#x8BD5;&#x3002;</em></p>
<p>&#x8FD9;&#x4E2A;&#x793A;&#x4F8B;&#x4E2D;&#xFF0C;&#x6211;&#x4EEC;&#x5C06;&#x57FA;&#x4E8E;&#x4E4B;&#x524D;&#x793A;&#x4F8B;&#x7684;&#x7ED3;&#x679C;&#xFF0C;&#x5E76;&#x4E14;&#x4E3A;CMake&#x9879;&#x76EE;&#x51C6;&#x5907;&#x4E00;&#x4E2A;&#x66F4;&#x771F;&#x5B9E;&#x548C;&#x590D;&#x6742;&#x7684;Conda&#x5305;&#xFF0C;&#x8FD9;&#x5C06;&#x53D6;&#x51B3;&#x4E8E;DGEMM&#x7684;&#x51FD;&#x6570;&#x5B9E;&#x73B0;&#xFF0C;&#x5BF9;&#x4E8E;&#x77E9;&#x9635;&#x4E0E;&#x77E9;&#x9635;&#x7684;&#x4E58;&#x6CD5;&#xFF0C;&#x53EF;&#x4EE5;&#x4F7F;&#x7528;Intel&#x7684;MKL&#x5E93;&#x8FDB;&#x884C;&#x3002;Intel&#x7684;MKL&#x5E93;&#x53EF;&#x4EE5;&#x4EE5;Conda&#x5305;&#x7684;&#x5F62;&#x5F0F;&#x63D0;&#x4F9B;&#x3002;&#x6B64;&#x793A;&#x4F8B;&#x5C06;&#x4E3A;&#x6211;&#x4EEC;&#x63D0;&#x4F9B;&#x4E00;&#x4E2A;&#x5DE5;&#x5177;&#x96C6;&#xFF0C;&#x7528;&#x4E8E;&#x51C6;&#x5907;&#x548C;&#x5171;&#x4EAB;&#x5177;&#x6709;&#x4F9D;&#x8D56;&#x5173;&#x7CFB;&#x7684;Conda&#x5305;&#x3002;</p>
<h2 id="&#x51C6;&#x5907;&#x5DE5;&#x4F5C;">&#x51C6;&#x5907;&#x5DE5;&#x4F5C;</h2>
<p>&#x5BF9;&#x4E8E;&#x8FD9;&#x4E2A;&#x793A;&#x4F8B;&#xFF0C;&#x6211;&#x4EEC;&#x5C06;&#x4F7F;&#x7528;&#x4E0E;&#x524D;&#x4E00;&#x4E2A;&#x793A;&#x4F8B;&#x4E2D;&#x7684;Conda&#x914D;&#x7F6E;&#xFF0C;&#x548C;&#x76F8;&#x540C;&#x7684;&#x6587;&#x4EF6;&#x547D;&#x540D;&#x548C;&#x76EE;&#x5F55;&#x7ED3;&#x6784;&#xFF1A;</p>
<pre><code class="lang-shell">.
&#x251C;&#x2500;&#x2500; CMakeLists.txt
&#x251C;&#x2500;&#x2500; conda-recipe
&#x2502;    &#x2514;&#x2500;&#x2500; meta.yaml
&#x2514;&#x2500;&#x2500; example.cpp
</code></pre>
<p>&#x793A;&#x4F8B;&#x6587;&#x4EF6;(<code>example.cpp</code>)&#x5C06;&#x6267;&#x884C;&#x77E9;&#x9635;-&#x77E9;&#x9635;&#x4E58;&#x6CD5;&#xFF0C;&#x5E76;&#x5C06;MKL&#x5E93;&#x8FD4;&#x56DE;&#x7684;&#x7ED3;&#x679C;&#x4E0E;&#x201C;noddy&#x201D;&#x5B9E;&#x73B0;&#x8FDB;&#x884C;&#x6BD4;&#x8F83;:</p>
<pre><code class="lang-c++">#include &quot;mkl.h&quot;

#include &lt;cassert&gt;
#include &lt;cmath&gt;
#include &lt;iostream&gt;
#include &lt;random&gt;

int main() {
  // generate a uniform distribution of real number between -1.0 and 1.0
  std::random_device rd;
  std::mt19937 mt(rd());
  std:: uniform_real_distribution &lt; double &gt; dist(-1.0, 1.0);

  int m = 500;
  int k = 1000;
  int n = 2000;

  double *A = (double *)mkl_malloc(m * k * sizeof(double), 64);
  double *B = (double *)mkl_malloc(k * n * sizeof(double), 64);
  double *C = (double *)mkl_malloc(m * n * sizeof(double), 64);
  double * D = new double[m * n];

  for (int i = 0; i &lt; (m * k); i++) {
    A[i] = dist(mt);
  }

  for (int i = 0; i &lt; (k * n); i++) {
    B[i] = dist(mt);
  }

  for (int i = 0; i &lt; (m * n); i++) {
    C[i] = 0.0;
  }

  double alpha = 1.0;
  double beta = 0.0;
  cblas_dgemm(CblasRowMajor,
              CblasNoTrans,
              CblasNoTrans,
              m,
              n,
              k,
              alpha,
              A,
              k,
              B,
              n,
              beta,
              C,
              n);

  // D_mn = A_mk B_kn
  for (int r = 0; r &lt; m; r++) {
    for (int c = 0; c &lt; n; c++) {
      D[r * n + c] = 0.0;
      for (int i = 0; i &lt; k; i++) {
        D[r * n + c] += A[r * k + i] * B[i * n + c];
      }
    }
  }

  // compare the two matrices
  double r = 0.0;
  for (int i = 0; i &lt; (m * n); i++) {
    r += std::pow(C[i] - D[i], 2.0);
  }
  assert (r &lt; 1.0e-12 &amp; &amp; &quot;ERROR: matrices C and D do not match&quot;);

  mkl_free(A);
  mkl_free(B);
  mkl_free(C);
  delete[] D;

  std:: cout &lt;&lt; &quot;MKL DGEMM example worked!&quot; &lt;&lt; std:: endl;

  return 0;`
}
</code></pre>
<p>&#x6211;&#x4EEC;&#x8FD8;&#x9700;&#x8981;&#x4FEE;&#x6539;<code>meta.yaml</code>&#x3002;&#x7136;&#x800C;&#xFF0C;&#x4E0E;&#x4E0A;&#x4E00;&#x4E2A;&#x793A;&#x4F8B;&#x76F8;&#x6BD4;&#xFF0C;&#x552F;&#x4E00;&#x7684;&#x53D8;&#x5316;&#x662F;&#x5728;&#x4F9D;&#x8D56;&#x9879;&#x4E2D;&#x52A0;&#x5165;&#x4E86;<code>mkl-devel</code>&#xFF1A;</p>
<pre><code class="lang-yaml"><span class="hljs-attr">package:</span>
<span class="hljs-attr">  name:</span> conda-example-dgemm
<span class="hljs-attr">  version:</span> <span class="hljs-string">&quot;0.0.0&quot;</span>

<span class="hljs-attr">source:</span>
<span class="hljs-attr">  path:</span> ../ <span class="hljs-comment"># this can be changed to git-url</span>

<span class="hljs-attr">build:</span>
<span class="hljs-attr">  number:</span> <span class="hljs-number">0</span>
<span class="hljs-attr">  script:</span>
<span class="hljs-bullet">  -</span> cmake -H. -Bbuild_conda -G <span class="hljs-string">&quot;${CMAKE_GENERATOR}&quot;</span>
<span class="hljs-bullet">  -</span>DCMAKE_INSTALL_PREFIX=${PREFIX} <span class="hljs-comment"># [not win]</span>
<span class="hljs-bullet">  -</span> cmake -H. -Bbuild_conda -G <span class="hljs-string">&quot;%CMAKE_GENERATOR%&quot;</span>
<span class="hljs-bullet">  -</span>DCMAKE_INSTALL_PREFIX=<span class="hljs-string">&quot;%LIBRARY_PREFIX%&quot;</span> <span class="hljs-comment"># [win]</span>
<span class="hljs-bullet">  -</span> cmake - -build build_conda - -target install

<span class="hljs-attr">requirements:</span>
<span class="hljs-attr">  build:</span>
<span class="hljs-bullet">    -</span> cmake &gt;=<span class="hljs-number">3.5</span>
<span class="hljs-bullet">    -</span> {{ compiler(<span class="hljs-string">&apos;cxx&apos;</span>) }}
<span class="hljs-attr">  host:</span>
<span class="hljs-bullet">    -</span> mkl - devel <span class="hljs-number">2018</span>

<span class="hljs-attr">about:</span>
<span class="hljs-attr">  home:</span> http://www.example.com
<span class="hljs-attr">  license:</span> MIT
<span class="hljs-attr">  summary:</span> <span class="hljs-string">&quot;Summary in here ...&quot;</span>
</code></pre>
<h2 id="&#x5177;&#x4F53;&#x5B9E;&#x65BD;">&#x5177;&#x4F53;&#x5B9E;&#x65BD;</h2>
<ol>
<li><p><code>CMakeLists.txt</code>&#x6587;&#x4EF6;&#x58F0;&#x660E;&#x4E86;&#x6700;&#x4F4E;&#x7248;&#x672C;&#x3001;&#x9879;&#x76EE;&#x540D;&#x79F0;&#x548C;&#x652F;&#x6301;&#x7684;&#x8BED;&#x8A00;&#xFF1A;</p>
<pre><code class="lang-cmake"><span class="hljs-keyword">cmake_minimum_required</span>(VERSION <span class="hljs-number">3.5</span> FATAL_ERROR)
<span class="hljs-keyword">project</span>(recipe-<span class="hljs-number">05</span> LANGUAGES CXX)
<span class="hljs-keyword">set</span>(CMAKE_CXX_STANDARD <span class="hljs-number">11</span>)
<span class="hljs-keyword">set</span>(CMAKE_CXX_EXTENSIONS <span class="hljs-keyword">OFF</span>)
<span class="hljs-keyword">set</span>(CMAKE_CXX_STANDARD_REQUIRED <span class="hljs-keyword">ON</span>)
</code></pre>
</li>
<li><p>&#x4F7F;&#x7528;<code>example.cpp</code>&#x6784;&#x5EFA;<code>dgem-example</code>&#x53EF;&#x6267;&#x884C;&#x76EE;&#x6807;&#xFF1A;</p>
<pre><code class="lang-cmake"><span class="hljs-keyword">add_executable</span>(dgemm-example <span class="hljs-string">&quot;&quot;</span>)
target_sources(dgemm-example
  PRIVATE
      example.cpp
  )
</code></pre>
</li>
<li><p>&#x7136;&#x540E;&#xFF0C;&#x9700;&#x8981;&#x627E;&#x5230;&#x901A;&#x8FC7;<code>MKL-devel</code>&#x5B89;&#x88C5;&#x7684;MKL&#x5E93;&#x3002;&#x6211;&#x4EEC;&#x51C6;&#x5907;&#x4E86;&#x4E00;&#x4E2A;&#x540D;&#x4E3A;<code>IntelMKL</code>&#x7684;<code>INTERFACE</code>&#x5E93;&#xFF0C;&#x8BE5;&#x5E93;&#x53EF;&#x4EE5;&#x7528;&#x4E8E;&#x5176;&#x4ED6;&#x76EE;&#x6807;&#xFF0C;&#x5E76;&#x5C06;&#x4E3A;&#x4F9D;&#x8D56;&#x7684;&#x76EE;&#x6807;&#x8BBE;&#x7F6E;&#x5305;&#x62EC;&#x76EE;&#x5F55;&#x3001;&#x7F16;&#x8BD1;&#x5668;&#x9009;&#x9879;&#x548C;&#x94FE;&#x63A5;&#x5E93;&#x3002;&#x6839;&#x636E;Intel&#x7684;&#x5EFA;&#x8BAE;(<a href="https://software.intel.com/en-us/articles/intel-mml-link-line-advisor/" target="_blank">https://software.intel.com/en-us/articles/intel-mml-link-line-advisor/</a> )&#x8FDB;&#x884C;&#x8BBE;&#x7F6E;&#x3002;&#x9996;&#x5148;&#xFF0C;&#x8BBE;&#x7F6E;&#x7F16;&#x8BD1;&#x5668;&#x9009;&#x9879;&#xFF1A;</p>
<pre><code class="lang-cmake"><span class="hljs-keyword">add_library</span>(IntelMKL INTERFACE)

target_compile_options(IntelMKL
  INTERFACE
      $&lt;$&lt;<span class="hljs-keyword">OR</span>:$&lt;CXX_COMPILER_ID:GNU&gt;,$&lt;CXX_COMPILER_ID:AppleClang&gt;&gt;:-m64&gt;
  )
</code></pre>
</li>
<li><p>&#x63A5;&#x4E0B;&#x6765;&#xFF0C;&#x67E5;&#x627E;<code>mkl.h</code>&#x5934;&#x6587;&#x4EF6;&#xFF0C;&#x5E76;&#x4E3A;<code>IntelMKL</code>&#x76EE;&#x6807;&#x8BBE;&#x7F6E;<code>include</code>&#x76EE;&#x5F55;&#xFF1A;</p>
<pre><code class="lang-cmake"><span class="hljs-keyword">find_path</span>(_mkl_h
  NAMES
      mkl.h
  HINTS
      <span class="hljs-variable">${CMAKE_INSTALL_PREFIX}</span>/<span class="hljs-keyword">include</span>
  )

target_include_directories(IntelMKL
  INTERFACE
      <span class="hljs-variable">${_mkl_h}</span>
  )

<span class="hljs-keyword">message</span>(STATUS <span class="hljs-string">&quot;MKL header file FOUND: ${_mkl_h}&quot;</span>)
</code></pre>
</li>
<li><p>&#x6700;&#x540E;&#xFF0C;&#x4E3A;<code>IntelMKL</code>&#x76EE;&#x6807;&#x8BBE;&#x7F6E;&#x94FE;&#x63A5;&#x5E93;:</p>
<pre><code class="lang-cmake"><span class="hljs-keyword">find_library</span>(_mkl_libs
  NAMES
    mkl_rt
  HINTS
    <span class="hljs-variable">${CMAKE_INSTALL_PREFIX}</span>/lib
  )
<span class="hljs-keyword">message</span>(STATUS <span class="hljs-string">&quot;MKL single dynamic library FOUND: ${_mkl_libs}&quot;</span>)

<span class="hljs-keyword">find_package</span>(Threads QUIET)
<span class="hljs-keyword">target_link_libraries</span>(IntelMKL
  INTERFACE
    <span class="hljs-variable">${_mkl_libs}</span>
    $&lt;$&lt;<span class="hljs-keyword">OR</span>:$&lt;CXX_COMPILER_ID:GNU&gt;,$&lt;CXX_COMPILER_ID:AppleClang&gt;&gt;:Threads::Threads&gt;
    $&lt;$&lt;<span class="hljs-keyword">OR</span>:$&lt;CXX_COMPILER_ID:GNU&gt;,$&lt;CXX_COMPILER_ID:AppleClang&gt;&gt;:m&gt;
  )
</code></pre>
</li>
<li><p>&#x4F7F;&#x7528;<code>cmake_print_properties</code>&#x51FD;&#x6570;&#xFF0C;&#x6253;&#x5370;<code>IntelMKL</code>&#x76EE;&#x6807;&#x7684;&#x4FE1;&#x606F;&#xFF1A;</p>
<pre><code class="lang-cmake"><span class="hljs-keyword">include</span>(CMakePrintHelpers)
cmake_print_properties(
  TARGETS
      IntelMKL
  PROPERTIES
    INTERFACE_COMPILE_OPTIONS
    INTERFACE_INCLUDE_DIRECTORIES
    INTERFACE_LINK_LIBRARIES
  )
</code></pre>
</li>
<li><p>&#x5C06;&#x8FD9;&#x4E9B;&#x5E93;&#x8FDE;&#x63A5;&#x5230;<code>dgem-example</code>:</p>
<pre><code class="lang-cmake"><span class="hljs-keyword">target_link_libraries</span>(dgemm-example
  PRIVATE
      IntelMKL
  )
</code></pre>
</li>
<li><p><code>CMakeLists.txt</code>&#x4E2D;&#x5B9A;&#x4E49;&#x4E86;&#x5B89;&#x88C5;&#x76EE;&#x6807;:</p>
<pre><code class="lang-cmake"><span class="hljs-keyword">install</span>(
  TARGETS
      dgemm-example
  DESTINATION
      bin
  )
</code></pre>
</li>
<li><p>&#x5C1D;&#x8BD5;&#x6784;&#x5EFA;&#x5305;&#xFF1A;</p>
<pre><code class="lang-shell">$ conda build conda-recipe
</code></pre>
</li>
<li><p>&#x8FC7;&#x7A0B;&#x4E2D;&#x5C4F;&#x5E55;&#x4E0A;&#x5C06;&#x770B;&#x5230;&#x5927;&#x91CF;&#x8F93;&#x51FA;&#xFF0C;&#x4F46;&#x662F;&#x4E00;&#x65E6;&#x6784;&#x5EFA;&#x5B8C;&#x6210;&#xFF0C;&#x5C31;&#x53EF;&#x4EE5;&#x5BF9;&#x5305;&#x8FDB;&#x884C;&#x5B89;&#x88C5;&#x5305;&#x3002;&#x9996;&#x5148;&#xFF0C;&#x5728;&#x672C;&#x5730;&#x8FDB;&#x884C;&#x5B89;&#x88C5;&#x6D4B;&#x8BD5;&#xFF1A;</p>
<pre><code class="lang-shell">$ conda install --use-local conda-example-dgemm
</code></pre>
</li>
<li><p>&#x73B0;&#x5728;&#x6D4B;&#x8BD5;&#x5B89;&#x88C5;&#xFF0C;&#x6253;&#x5F00;&#x4E00;&#x4E2A;&#x65B0;&#x7684;&#x7EC8;&#x7AEF;(&#x5047;&#x8BBE;Anaconda&#x5904;&#x4E8E;&#x6FC0;&#x6D3B;&#x72B6;&#x6001;)&#xFF0C;&#x5E76;&#x8F93;&#x5165;&#xFF1A;</p>
<pre><code class="lang-shell">$ dgemm-example

MKL DGEMM example worked!
</code></pre>
</li>
<li><p>&#x5B89;&#x88C5;&#x6210;&#x529F;&#x4E4B;&#x540E;&#xFF0C;&#x518D;&#x8FDB;&#x884C;&#x5378;&#x8F7D;&#xFF1A;</p>
<pre><code class="lang-shell">$ conda remove conda-example-dgemm
</code></pre>
</li>
</ol>
<h2 id="&#x5DE5;&#x4F5C;&#x539F;&#x7406;">&#x5DE5;&#x4F5C;&#x539F;&#x7406;</h2>
<p><code>meta.yaml</code>&#x4E2D;&#x7684;&#x53D8;&#x5316;&#x5C31;&#x662F;<code>mml-devel</code>&#x4F9D;&#x8D56;&#x9879;&#x3002;&#x4ECE;CMake&#x7684;&#x89D2;&#x5EA6;&#x6765;&#x770B;&#xFF0C;&#x8FD9;&#x91CC;&#x7684;&#x6311;&#x6218;&#x662F;&#x5B9A;&#x4F4D;Anaconda&#x5B89;&#x88C5;&#x7684;MKL&#x5E93;&#x3002;&#x5E78;&#x8FD0;&#x7684;&#x662F;&#xFF0C;&#x6211;&#x4EEC;&#x77E5;&#x9053;&#x5B83;&#x4F4D;&#x4E8E;<code>${CMAKE_INSTALL_PREFIX}</code>&#x4E2D;&#x3002;&#x53EF;&#x4EE5;&#x4F7F;&#x7528;&#x5728;&#x7EBF;&#x7684;<code>Intel MKL link line advisor</code>(<a href="https://software.intel.com/en-us/articles/intel-mml-link-line-advisor/" target="_blank">https://software.intel.com/en-us/articles/intel-mml-link-line-advisor/</a>) &#x67E5;&#x770B;&#x5982;&#x4F55;&#x6839;&#x636E;&#x9009;&#x62E9;&#x7684;&#x5E73;&#x53F0;&#x548C;&#x7F16;&#x8BD1;&#x5668;&#xFF0C;&#x5C06;MKL&#x94FE;&#x63A5;&#x5230;&#x6211;&#x4EEC;&#x7684;&#x9879;&#x76EE;&#x4E2D;&#xFF0C;&#x6211;&#x4EEC;&#x4F1A;&#x5C06;&#x6B64;&#x4FE1;&#x606F;&#x5C01;&#x88C5;&#x5230;<code>INTERFACE</code>&#x5E93;&#x4E2D;&#x3002;&#x8FD9;&#x4E2A;&#x89E3;&#x51B3;&#x65B9;&#x6848;&#x975E;&#x5E38;&#x9002;&#x5408;&#x7C7B;MKL&#x7684;&#x60C5;&#x51B5;&#xFF1A;&#x5E93;&#x4E0D;&#x662F;&#x7531;&#x6211;&#x4EEC;&#x7684;&#x9879;&#x76EE;&#x6216;&#x4EFB;&#x4F55;&#x5B50;&#x9879;&#x76EE;&#x521B;&#x5EFA;&#x7684;&#x76EE;&#x6807;&#xFF0C;&#x4F46;&#x662F;&#x5B83;&#x4ECD;&#x7136;&#x9700;&#x8981;&#x4EE5;&#x4E00;&#x79CD;&#x65B9;&#x5F0F;&#x8FDB;&#x884C;&#x5904;&#x7406;&#xFF1B;&#x4E5F;&#x5C31;&#x662F;&#xFF1A;&#x8BBE;&#x7F6E;&#x7F16;&#x8BD1;&#x5668;&#x6807;&#x5FD7;&#xFF0C;&#x5305;&#x62EC;&#x76EE;&#x5F55;&#x548C;&#x94FE;&#x63A5;&#x5E93;&#x3002;<code>INTERFACE</code>&#x5E93;&#x662F;&#x6784;&#x5EFA;&#x7CFB;&#x7EDF;&#x4E2D;&#x7684;&#x76EE;&#x6807;&#xFF0C;&#x4F46;&#x4E0D;&#x521B;&#x5EFA;&#x4EFB;&#x4F55;&#x6784;&#x5EFA;&#x8F93;&#x51FA;(&#x81F3;&#x5C11;&#x4E0D;&#x4F1A;&#x76F4;&#x63A5;&#x521B;&#x5EFA;)&#x3002;&#x4F46;&#x7531;&#x4E8E;&#x5B83;&#x4EEC;&#x662F;&#x76EE;&#x6807;&#xFF0C;&#x6211;&#x4EEC;&#x53EF;&#x5BF9;&#x5B83;&#x4EEC;&#x7684;&#x5C5E;&#x6027;&#x8FDB;&#x884C;&#x8BBE;&#x7F6E;&#x3002;&#x8FD9;&#x6837;&#x4E0E;&#x201C;&#x5B9E;&#x9645;&#x201D;&#x76EE;&#x6807;&#x4E00;&#x6837;&#xFF0C;&#x53EF;&#x4EE5;&#x5B89;&#x88C5;&#x3001;&#x5BFC;&#x51FA;&#x548C;&#x5BFC;&#x5165;&#x3002;</p>
<p>&#x9996;&#x5148;&#xFF0C;&#x6211;&#x4EEC;&#x7528;<code>INTERFACE</code>&#x5C5E;&#x6027;&#x58F0;&#x660E;&#x4E00;&#x4E2A;&#x540D;&#x4E3A;<code>IntelMKL</code>&#x7684;&#x65B0;&#x5E93;&#x3002;&#x7136;&#x540E;&#xFF0C;&#x6839;&#x636E;&#x9700;&#x8981;&#x8BBE;&#x7F6E;&#x5C5E;&#x6027;&#xFF0C;&#x5E76;&#x4F7F;&#x7528;<code>INTERFACE</code>&#x5C5E;&#x6027;&#x5728;&#x76EE;&#x6807;&#x4E0A;&#x8C03;&#x7528;&#x9002;&#x5F53;&#x7684;CMake&#x547D;&#x4EE4;&#xFF1A;</p>
<ul>
<li>target_compile_options&#xFF1A;&#x7528;&#x4E8E;&#x8BBE;&#x7F6E;<code>INTERFACE_COMPILE_OPTIONS</code>&#x3002;&#x793A;&#x4F8B;&#x4E2D;&#xFF0C;&#x8BBE;&#x7F6E;&#x4E86;<code>-m64</code>&#xFF0C;&#x4E0D;&#x8FC7;&#x8FD9;&#x4E2A;&#x6807;&#x5FD7;&#x53EA;&#x6709;GNU&#x548C;AppleClange&#x7F16;&#x8BD1;&#x5668;&#x80FD;&#x591F;&#x8BC6;&#x522B;&#x3002;&#x5E76;&#x4E14;&#xFF0C;&#x6211;&#x4EEC;&#x4F7F;&#x7528;&#x751F;&#x6210;&#x5668;&#x8868;&#x8FBE;&#x5F0F;&#x6765;&#x5B9E;&#x73B0;&#x3002;</li>
<li>target_include_directories&#xFF1A;&#x7528;&#x4E8E;&#x8BBE;&#x7F6E;<code>INTERFACE_INCLUDE_DIRECTORIES</code>&#x3002;&#x4F7F;&#x7528;<code>find_path</code>&#xFF0C;&#x53EF;&#x4EE5;&#x5728;&#x627E;&#x5230;&#x7CFB;&#x7EDF;&#x4E0A;&#x7684;<code>mkl.h</code>&#x5934;&#x6587;&#x4EF6;&#x540E;&#x8BBE;&#x7F6E;&#x8FD9;&#x4E9B;&#x53C2;&#x6570;&#x3002;</li>
<li>target_link_libraries&#xFF1A;&#x7528;&#x4E8E;&#x8BBE;&#x7F6E;<code>INTERFACE_LINK_LIBRARIES</code>&#x3002;&#x6211;&#x4EEC;&#x51B3;&#x5B9A;&#x94FE;&#x63A5;&#x52A8;&#x6001;&#x5E93;<code>libmkl_rt.so</code>&#xFF0C;&#x5E76;&#x7528;<code>find_library</code>&#x641C;&#x7D22;&#x5B83;&#x3002;GNU&#x6216;AppleClang&#x7F16;&#x8BD1;&#x5668;&#x8FD8;&#x9700;&#x8981;&#x5C06;&#x53EF;&#x6267;&#x884C;&#x6587;&#x4EF6;&#x94FE;&#x63A5;&#x5230;&#x7EBF;&#x7A0B;&#x548C;&#x6570;&#x5B66;&#x5E93;&#x3002;&#x540C;&#x6837;&#xFF0C;&#x8FD9;&#x4E9B;&#x60C5;&#x51B5;&#x53EF;&#x4EE5;&#x4F7F;&#x7528;&#x751F;&#x6210;&#x5668;&#x8868;&#x8FBE;&#x5F0F;&#x4F18;&#x96C5;&#x5730;&#x8FDB;&#x884C;&#x5904;&#x7406;&#x3002;</li>
</ul>
<p>&#x5728;<code>IntelMKL</code>&#x76EE;&#x6807;&#x4E0A;&#x8BBE;&#x7F6E;&#x7684;&#x5C5E;&#x6027;&#x540E;&#xFF0C;&#x53EF;&#x4EE5;&#x901A;&#x8FC7;<code>cmake_print_properties</code>&#x547D;&#x4EE4;&#x5C06;&#x5C5E;&#x6027;&#x8FDB;&#x884C;&#x6253;&#x5370;&#x3002;&#x6700;&#x540E;&#xFF0C;&#x94FE;&#x63A5;&#x5230;<code>IntelMKL</code>&#x76EE;&#x6807;&#xFF0C;&#x8FD9;&#x5C06;&#x8BBE;&#x7F6E;&#x7F16;&#x8BD1;&#x5668;&#x6807;&#x5FD7;&#xFF0C;&#x5305;&#x62EC;&#x76EE;&#x5F55;&#x548C;&#x94FE;&#x63A5;&#x5E93;&#xFF1A;</p>
<pre><code class="lang-cmake"><span class="hljs-keyword">target_link_libraries</span>(dgemm-example
  PRIVATE
      IntelMKL
  )
</code></pre>
<h2 id="&#x66F4;&#x591A;&#x4FE1;&#x606F;">&#x66F4;&#x591A;&#x4FE1;&#x606F;</h2>
<p>Anaconda&#x4E91;&#x4E0A;&#x5305;&#x542B;&#x5927;&#x91CF;&#x5305;&#x3002;&#x4F7F;&#x7528;&#x4E0A;&#x8FF0;&#x65B9;&#x6CD5;&#xFF0C;&#x53EF;&#x4EE5;&#x4E3A;CMake&#x9879;&#x76EE;&#x6784;&#x5EFA;&#x4F9D;&#x8D56;&#x4E8E;&#x5176;&#x4ED6;Conda&#x5305;&#x7684;Conda&#x5305;&#x3002;&#x8FD9;&#x6837;&#xFF0C;&#x5C31;&#x53EF;&#x4EE5;&#x63A2;&#x7D22;&#x8F6F;&#x4EF6;&#x529F;&#x80FD;&#x7684;&#x5404;&#x79CD;&#x53EF;&#x80FD;&#x6027;&#xFF0C;&#x5E76;&#x4E0E;&#x4ED6;&#x4EBA;&#x5206;&#x4EAB;&#x60A8;&#x7684;&#x8F6F;&#x4EF6;&#x5305;!</p>

                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="11.4-chinese.html" class="navigation navigation-prev " aria-label="Previous page: 11.4 以Conda包的形式发布一个简单的项目">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="../chapter12/12.0-chinese.html" class="navigation navigation-next " aria-label="Next page: 第12章 构建文档">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"11.5 将Conda包作为依赖项发布给项目","level":"1.14.5","depth":2,"next":{"title":"第12章 构建文档","level":"1.15","depth":1,"path":"content/chapter12/12.0-chinese.md","ref":"content/chapter12/12.0-chinese.md","articles":[{"title":"12.1 使用Doxygen构建文档","level":"1.15.1","depth":2,"path":"content/chapter12/12.1-chinese.md","ref":"content/chapter12/12.1-chinese.md","articles":[]},{"title":"12.2 使用Sphinx构建文档","level":"1.15.2","depth":2,"path":"content/chapter12/12.2-chinese.md","ref":"content/chapter12/12.2-chinese.md","articles":[]},{"title":"12.3 结合Doxygen和Sphinx","level":"1.15.3","depth":2,"path":"content/chapter12/12.3-chinese.md","ref":"content/chapter12/12.3-chinese.md","articles":[]}]},"previous":{"title":"11.4 以Conda包的形式发布一个简单的项目","level":"1.14.4","depth":2,"path":"content/chapter11/11.4-chinese.md","ref":"content/chapter11/11.4-chinese.md","articles":[]},"dir":"ltr"},"config":{"plugins":["-lunr","-search","search-pro","-sharing","github","pageview-count"],"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"github":{"url":"https://github.com/arcticfox1919"},"search-pro":{},"pageview-count":{},"highlight":{},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"theme":"default","author":"陈晓伟 chenxiaowei","pdf":{"pageNumbers":false,"fontSize":30,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":30,"left":30,"top":30,"bottom":50}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"《CMake Cookbook》中文版","language":"zh-hans","gitbook":"*","description":"作为对《CMake Cookbook》英文版的中文翻译。","direction":"ltr"},"file":{"path":"content/chapter11/11.5-chinese.md","mtime":"2020-09-22T10:53:40.973Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2020-09-22T11:21:21.825Z"},"basePath":"../..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../../gitbook/gitbook.js"></script>
    <script src="../../gitbook/theme.js"></script>
    
        
        <script src="../../gitbook/gitbook-plugin-search-pro/jquery.mark.min.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-search-pro/search.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-github/plugin.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-pageview-count/plugin.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    </body>
</html>

